﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace BJoin.DapperExtension.DatabaseFactory
{
    public interface IDataProvider<TDatabase>
        where TDatabase : IDisposable
    {
        Task<TReturn> UsingAsync<TReturn>(Func<TDatabase, Task<TReturn>> func);
        Task UsingAsync(Func<TDatabase, Task> func);
    }


    public interface IShardingDataProvider<TDatabase, TShardingKey>
        where TDatabase : IDisposable
    {
        Task<TReturn> UsingAsync<TReturn>(Func<TDatabase, Task<TReturn>> func);
        Task UsingAsync(Func<TDatabase, Task> func);
        //
        Task<TReturn> UsingAsync<TReturn>(Func<TDatabase, Task<TReturn>> func, ReadWrite readWrite);
        Task UsingAsync(Func<TDatabase, Task> func, ReadWrite readWrite);
        Task<TReturn> ReadAsync<TReturn>(Func<TDatabase, Task<TReturn>> func);
        Task<TReturn> WriteAsync<TReturn>(Func<TDatabase, Task<TReturn>> func);
        Task ReadAsync(Func<TDatabase, Task> func);
        Task WriteAsync(Func<TDatabase, Task> func);
        //
        Task<TReturn> UsingAsync<TReturn>(Func<TDatabase, Task<TReturn>> func, ReadWrite readWrite, TShardingKey shardingKey);
        Task UsingAsync(Func<TDatabase, Task> func, ReadWrite readWrite, TShardingKey shardingKey);
        Task<TReturn> WriteAsync<TReturn>(Func<TDatabase, Task<TReturn>> func, TShardingKey shardingKey);
        Task<TReturn> ReadAsync<TReturn>(Func<TDatabase, Task<TReturn>> func, TShardingKey shardingKey);
        Task WriteAsync(Func<TDatabase, Task> func, TShardingKey shardingKey);
        Task ReadAsync(Func<TDatabase, Task> func, TShardingKey shardingKey);
    }
}
